//@ts-ignore
import knightPng from "res://assets/knight.png";
import BaseMove from "./base_move";
export default class KnightMove extends godot.Node2D {
    constructor() {
        // 构造函数必须先调用super()
        super();
        this.frameIndex = 10;
        this.frameStart = 10;
        this.frameEnd = 19;
        // 添加纹理信息
        this.position = new godot.Vector2(300, 300);
        let spr = new godot.Sprite();
        spr.texture = knightPng;
        spr.set_hframes(10);
        spr.set_vframes(2);
        this.frameIndex = this.frameStart;
        spr.set_frame(this.frameIndex);
        this.add_child(spr);
        // 移动控制
        let baseMove = new BaseMove();
        baseMove.isInputMove = true;
        // 信号都是字符串传递
        baseMove.connect("OnUpdatePos", (face) => {
            if (face == 3) {
                spr.scale = new godot.Vector2(-1, 1);
            }
            else if (face == 4) {
                spr.scale = new godot.Vector2(1, 1);
            }
            if (this.frameIndex < this.frameEnd) {
                this.frameIndex = this.frameIndex + 0.3;
            }
            else {
                this.frameIndex = this.frameStart;
            }
            this.frameIndex = this.frameIndex > this.frameEnd ? this.frameEnd : this.frameIndex;
            spr.set_frame(Math.floor(this.frameIndex));
        });
        this.add_child(baseMove);
    }
}
//# sourceMappingURL=knight_move.jsx.map